public class Page implements Searchable {
	//Fields
	private String title;
	private String text;
	
	//Getters and Setters
	public String getTitle(){
		return this.title;
	}
	
	public String getText() {
		return text;
	}

	public void setText(String text) {
		if(text != null){
			this.text = text;
		}
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	//Constructors
	
	public Page(){
		this.setText("");
		this.setTitle("");
	}
	
	public Page(String title, String text){
		this();
		this.setTitle(title);
		this.setText(text);
	}
	
	//Methods
	void addText(String text){
		String pageText = this.getText();
		if(text == null){
			text = "";
		}
		pageText += text;
		this.setText(pageText);
	}
	
	void deleteText(){
		this.setText("");
	}
	
	String viewPage(){
		return this.toString();
	}
	
	@Override
	public String toString() {
		return "PAGE TITLE: "+ this.getTitle()+"\n\n"+this.getText();
	}

	@Override
	public boolean searchWord(String word) {
		if(word != null){
			return this.getText().contains(word);
		}
		return false;
	}
	
	public boolean containsDigits(){
		String textToCheck = this.getText();
		for(int i = 0; i < textToCheck.length();i++){
			char symbol = textToCheck.charAt(i);
			if(Character.isDigit(symbol)){
				return true;
			}
		}
		return false;
	}
}
